#include "PreCompiled.h"
#include "Workbench.h"
#include "DockWindowManager.h"
#include "ToolBarItem.h"
#include "MenuManager.h"
#include "Application_App.h"
#include "Document_App.h"
TYPESYSTEM_SOURCE_ABSTRACT(Workbench,Base::BaseClass)
Workbench::Workbench(void)
:_name("")
{
}

Workbench::~Workbench(void)
{
}

std::string Workbench::name()const
{
  return _name;
}

void Workbench::setName(const std::string& name)
{
    _name = name;
}

bool Workbench::activate()
{
	ToolBarItem* tb = setupToolBars();
	ToolBarManager::getInstance()->setup(tb);
	delete tb;



   DockWindowItems* dw = setupDockWindows();
   DockWindowManager::instance()->setup(dw);
   delete dw;

   MenuItem* mb = setupMenuBar();
   MenuManager::Instance()->setup(mb);
   delete mb;

   GetApplication().newDocument();

   GetApplication().getActiveDocument()->addObject("Part::furniture_chair","objectname");
   return true;
}
ToolBarItem* Workbench::setupCommandBars()const
{
    return NULL;
}
DockWindowItems* Workbench::setupDockWindows()const
{
	DockWindowItems* root = new DockWindowItems;
	root->addDockWidget("Std_CombiView", Qt::LeftDockWidgetArea, false, false);
	root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, true);
   return root;
}
ToolBarItem* Workbench::setupToolBars()const
{
	ToolBarItem* root = new ToolBarItem;

	ToolBarItem* file = new ToolBarItem(root);

	file->setCommand("File");
	*file<< "Std_Reset"<<"Std_Open"<<"Std_Save"<<"Std_Quit";

	ToolBarItem* view = new ToolBarItem(root);
	view->setCommand("View");
	*view << "Std_ViewFitAll" << "Separator" <<"Std_ViewFront" << "Std_ViewRear" << "Std_ViewRight" << "Std_ViewLeft" << "Std_ViewTop" <<"Std_ViewBottom";


   return root;
}

MenuItem* Workbench::setupMenuBar()const
{
	MenuItem* root = new MenuItem;
	MenuItem* file = new MenuItem(root);

	file->setComamnd("&File");
	*file<< "Std_Reset"<<"Std_Open"<<"Std_Save"<<"Std_Import"<<"Std_Quit";

	MenuItem* view = new MenuItem(root);
	view->setComamnd("&View");
	*view << "Std_ViewFitAll" << "Separator" <<"Std_ViewDockUndockFullscreen"<<"Separator"<<"Std_ViewFront" << "Std_ViewRear" << "Std_ViewRight" << "Std_ViewLeft" << "Std_ViewTop" <<"Std_ViewBottom";

	return root;
}

void Workbench::setupContextMenu(const char* recipient,MenuItem* items)const
{
    if(strcmp(recipient,"View") == 0)
	{
		MenuItem* StdViews = new MenuItem;
		StdViews->setComamnd("standard views");

		*StdViews << "Std_ViewTop" <<"Std_ViewBottom"<< "Std_ViewFront" << " Std_ViewRight" <<"Std_ViewLeft";

		*items << "Std_ViewFitAll" << "Std_ViewFitSelection" << StdViews
			   << "Separator" << "Std_ViewDockUndockFullscreen";
	}
}
